char b,c[11];g(char*a,char*b){return*a-*b;}f(n){return n?n*f(n-1):1;}main(r,i,t,l){for(gets(c);gets(c);printf("%d\n",f(l)/r))for(l=strlen(c),qsort(c,l,1,g),r=1,b=*c,i=t=0;i<=l;i++,t++)if(b!=c[i])r*=f(t),t=0,b=c[i];}
